import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/7 16:00
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] price = {8,6,7,7};
        System.out.println(solution.getDescentPeriods(price));
    }
    public long getDescentPeriods(int[] prices) {
        int n = prices.length;
        long ans = 0;
        for (int left = 0; left < n; left++) {
            int i = left;
            while (left < n - 1 && prices[left] - prices[left + 1] == 1) {
                left++;
            }
            int m = left - i + 1;
            ans += (long) m * (m + 1) / 2;
        }
        return ans;
    }
}
